package Json;




import entity.Person;

import java.io.*;

/**
 * @author Ajie
 * @date 2023/8/1
 * @function
 */
public class SerializableTest {
    public static void main(String args[]) throws Exception{

        File file = new File("./src/Json/SerializableTest_Person_out.txt");

        FileOutputStream fos = new FileOutputStream(file);
        ObjectOutputStream out = new ObjectOutputStream(fos);
        Person personOrigin = new Person("张三",18);
        out.writeObject(personOrigin);
        out.close();

        FileInputStream fis = new FileInputStream(file);
        ObjectInputStream in = new ObjectInputStream(fis);
        Person newPerson = (Person)in.readObject();
        in.close();
        System.out.println("new person:"+newPerson.toString());

    }
//————————————————
//    版权声明：本文为CSDN博主「李一恩」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//    原文链接：https://blog.csdn.net/qq_29966203/article/details/90605164
}
